#include "./traversal.cpp"

/** 创建一个demo二叉树
     A
    / \
   B   C
  /   /
 D   E
  \
   F             **/
BiTree buildBiTree();

int main()
{
    BiTree tree = buildBiTree();

    printf("[Binary Tree]\n");
    printTree(tree, 0, 0);

    printf("\n[PreOrder]\t");
    PreOrder(tree);

    printf("\n[InOrder]\t");
    InOrder(tree);

    printf("\n[PostOrder]\t");
    PostOrder(tree);

    printf("\n[PreOrder non-recursive]\t");
    PreOrderNonRecursive(tree);

    printf("[InOrder non-recursive]\t\t");
    InOrderNonRecursive(tree);

    printf("[PostOrder non-recursive]\t");
    PostOrderNonRecursive(tree);

    printf("[LevelOrder]\t");
    LevelOrder(tree);

    return 0;
}

BiTree buildBiTree()
{
    // 创建一个二叉树
    BiTree root = (BiTNode *)malloc(sizeof(BiTNode));
    BiTNode *B = (BiTNode *)malloc(sizeof(BiTNode));
    BiTNode *C = (BiTNode *)malloc(sizeof(BiTNode));
    BiTNode *D = (BiTNode *)malloc(sizeof(BiTNode));
    BiTNode *E = (BiTNode *)malloc(sizeof(BiTNode));
    BiTNode *F = (BiTNode *)malloc(sizeof(BiTNode));
    root->data = 'A';
    B->data = 'B';
    C->data = 'C';
    D->data = 'D';
    E->data = 'E';
    F->data = 'F';
    root->lchild = B;
    root->rchild = C;
    B->lchild = D;
    C->lchild = E;
    D->rchild = F;
    return root;
}